import java.util.concurrent.atomic.AtomicInteger;

import static java.lang.Character.isLetter;

class RotationalCipher {
    private static final char _a;
    private static final char _z;
    private static final char _A;
    private static final char _Z;
    private static final ThreadLocal<AtomicInteger> HOOP;

    static {
        _Z = 'Z';
        _A = 'A';
        _z = 'z';
        _a = 'a';
        HOOP = ThreadLocal.withInitial(() -> new AtomicInteger(26));
    }

    private int cipher;

    RotationalCipher(int cipher) {
        this.cipher = cipher;
    }

    String rotate(String inputString) {
        char[] results = new char[inputString.length()];

        char tmp;
        for (int i = 0; i < inputString.length(); i++) {
            tmp = inputString.charAt(i);

            if (!isLetter(tmp)) {
                results[i] = tmp;
                continue;
            }

            if (tmp >= RotationalCipher._a && tmp <= RotationalCipher._z) {
                results[i] = (char) ((tmp - RotationalCipher._a
                        + this.cipher) % RotationalCipher.HOOP.get().get() + RotationalCipher._a);
                continue;
            }

            if (tmp >= RotationalCipher._A && tmp <= RotationalCipher._Z) {
                results[i] = (char) ((tmp - RotationalCipher._A
                        + this.cipher) % RotationalCipher.HOOP.get().get() + RotationalCipher._A);
            }
        }

        return new String(results);
    }
}